<?php
 
	function smarty_block_general($params, $content, &$smarty, &$repeat) {

		global $db, $config;

		$l = count($smarty->_tag_stack);

		if(empty($smarty->blockvars[$l])) {
			$sqlstr = "select * from {$config->db_prefix}general where 1=1";
			if ($params['setting_admin']){
				$sqlstr .= " and admin_name = ".$db->qstr($params['setting_admin']);
			}else{
				$sqlstr .= " and admin_name = ".$db->qstr($_SESSION['ADMIN_USER']);
			}

			$limit = empty($params['limit'])?9999:$params['limit'];
			$page = empty($params['page'])?1:$params['page'];
			$pager = new pager($limit, $page);
			$smarty->blockvars[$l] = $pager->execute($db, $sqlstr);

			//
			if(!$smarty->blockvars[$l]) return $repeat = false;
			if(!empty($params['pager'])) $smarty->assign($params['pager'], $pager);
		}
	
		if(list($key, $item) = each($smarty->blockvars[$l])) {
			$repeat = true;
			$smarty->assign('general', $item);
		}
		else {
			$repeat = false;
			reset($smarty->blockvars[$l]);
		}
		
		if(!is_null($content)) print $content;
	
		//
		if(!$repeat) $smarty->blockvars[$l] = array();
	}

?>